﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/js/nhatkybanhang.js") %>"></script>

<% List<Data.DBOES.NhatKyBanHang> objList = (List<Data.DBOES.NhatKyBanHang>)ViewData["ListNKBH"];
      if (objList.Count > 0)
      {
          int idpage = (int)ViewData["IdForm"];
                   %>
        <td valign="top">
			<div class="firstcol">           
                   <table class="LeftTable" cellspacing="0" cellpadding="0" >
                   <%
                       int limitpage = (int)ViewData["LimitPage"];
                    int currpage = (int)ViewData["PageCurr"];
                       int stt = 1;
                    foreach (var obj in objList)
                    { 
                    %>
                    <tr>
                    <td class="tableFirstCol" style="width:50px;"><%: (stt+(limitpage*(currpage-1))).ToString()%></td>
						<td class="tableFirstCol">
                        	<a href="javascript:Delete(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><img src="/Content/images/add.png" alt="Xóa NKBH" title="Xóa dòng <%= obj.ChuHang %>"/></a>
                            <a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><img src="/Content/images/edit.png" alt="Sửa NKBH"  title="Sửa dòng <%= obj.ChuHang %>"/></a>
                            <% if (obj.IsActive == false)
                               { 
                                %>
                                <a href="javascript:OK(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><img src="/Content/images/ok.jpg" alt="Duyệt dòng đã sửa"  title="Duyệt dòng đã sửa"/></a>
                                <%
                               }      
                              %>
                            
                        </td>
                        
						<td><%: ((DateTime)obj.NgayBan).ToString("dd/MM/yyyy")%></td>
					</tr>
                    <%
                        stt++;
                    }
                   %>
                   </table>
			</div>
		</td>
		
		<td valign="top">
			<div class="table_div" onscroll="fnScroll()" >
				<table class="MainTable" cellspacing="0" cellpadding="0" >
                   <%
                       int count = 1;
                    foreach (var obj in objList)
                    {
                        if (count == 1)
                        {
                            if (obj.IsActive==true)
                            {
                                %>
                                 <tr class='firstTr'>
                                <%
                            }
                            else
                            { 
                                %>
                                 <tr class='firstTr' style="background:url('/Content/images/bg_td_false.png') repeat-x">
                                <%
                            }
                            %>
                            
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title="<%= obj.ChuHang %>"><%= obj.ChuHang.ToString().Length > 30 ? obj.ChuHang.ToString().Substring(0, 30) : obj.ChuHang.ToString()%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.DiaChi%></a> </td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.PL%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.GiaNhap)).ToString()) + "-đ"%></a></td>
						        <td><% using (Ajax.BeginForm("TraTienMuoiNhap", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>
                                    <%: Html.TextBox("IdNKBH_TraTienMuoiNhap", obj.IdNKBH, new { style = "display:none" })%>
                                    <%: Html.CheckBox("TraTienMuoiNhap", LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraTienMuoiNhap, false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoXeTangBo%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.CuocXeTangBo.ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.CuocXeTangBo)).ToString()) + "-đ"%></a></td>
                                <td>
                                <% using (Ajax.BeginForm("TraCuocTB", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>
                                    <%: Html.TextBox("IdNKBH_TraCuocTB", obj.IdNKBH, new { style = "display:none" })%>
                                    <%: Html.CheckBox("TraCuocTB", LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraCuocTB, false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %>
                                </td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.DiaDiemTangBo%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoLuong%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoXeVanChuyen%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.CuocXeVanChuyen.ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.CuocXeVanChuyen)).ToString()) + "-đ"%></a></td>
                                <td>
                                <% using (Ajax.BeginForm("TraCuocVC", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>
                                    <%: Html.TextBox("IdNKBH_TraCuocVC", obj.IdNKBH, new { style = "display:none" })%>
                                    <%: Html.CheckBox("TraCuocVC", LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraCuocVC, false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %>
                                </td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SanPham%> </a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaNhap.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaBaoBiBocVac.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.GiaNhap) + Utilities.Protector.Double(obj.CuocXeTangBo) + Utilities.Protector.Double(obj.GiaBaoBiBocVac)).ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(((Utilities.Protector.Double(obj.GiaNhap) + Utilities.Protector.Double(obj.CuocXeTangBo) + Utilities.Protector.Double(obj.GiaBaoBiBocVac)) * Utilities.Protector.Double(obj.SoLuong)).ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.NhapXuat%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaXuat.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0) * LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaXuat, 0))) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.BenTraVanChuyen%></a></td>                                
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.NoThu.ToString()) + "-đ"%></a></td>
                                <% if (obj.IdKhachHang >0)
                                   {
                                   %>
                                   <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title="<%= obj.KhachHang.MembershipName %>"><%= obj.KhachHang.MembershipName.ToString().Length > 30 ? obj.KhachHang.MembershipName.ToString().Substring(0, 30) : obj.KhachHang.MembershipName.ToString()%></a></td>
                                   <%
                                   }
                                   else
                                   { 
                                    %>
                                    <td></td>
                                   <%
                                   }
                                        %>
						        
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.ThanhToanTruoc, 0))) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.HinhThucTT  %></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.NoThu, 0) - LamSon.Commons.DataTypeProtect.ProtectDouble(obj.ThanhToanTruoc,0))) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString((
                                                            (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaXuat, 0) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0)) -
                                                            (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.CuocXeTangBo, 0) +
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaNhap, 0) +
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaBaoBiBocVac, 0)) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0)) -
                                                             (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.CuocXeVanChuyen, 0)))) + "-đ"%></a></td>
                                
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.GhiChu%></a></td>
                                
					        </tr>
                            <%
                            count++;
                        }
                        else
                        { 
                             if (obj.IsActive==true)
                            {
                                %>
                                 <tr>
                                <%
                            }
                            else
                            { 
                                %>
                                 <tr style="background:url('/Content/images/bg_td_false.png') repeat-x">
                                <%
                            }
                         
                            %>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title="<%= obj.ChuHang %>"><%= obj.ChuHang.ToString().Length > 30 ? obj.ChuHang.ToString().Substring(0, 30) : obj.ChuHang.ToString()%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.DiaChi%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.PL%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.GiaNhap)).ToString()) + "-đ"%></a></td>
						        <td><% using (Ajax.BeginForm("TraTienMuoiNhap", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>       
                                    <%: Html.TextBox("IdNKBH_TraTienMuoiNhap", obj.IdNKBH, new { style = "display:none" })%>                             
                                    <%: Html.CheckBox("TraTienMuoiNhap",LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraTienMuoiNhap,false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoXeTangBo%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.CuocXeTangBo.ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.CuocXeTangBo)).ToString()) + "-đ"%></a></td>
                                <td><% using (Ajax.BeginForm("TraCuocTB", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>
                                    <%: Html.TextBox("IdNKBH_TraCuocTB", obj.IdNKBH, new { style = "display:none" })%>
                                    <%: Html.CheckBox("TraCuocTB", LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraCuocTB, false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.DiaDiemTangBo%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoLuong%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SoXeVanChuyen%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.CuocXeVanChuyen.ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.SoLuong) * Utilities.Protector.Double(obj.CuocXeVanChuyen)).ToString()) + "-đ"%></a></td>
                                <td> <% using (Ajax.BeginForm("TraCuocVC", "NhatKyBanHang", new AjaxOptions { UpdateTargetId = "" }))
                                   { 
                                    %>
                                    <%: Html.TextBox("IdNKBH_TraCuocVC", obj.IdNKBH, new { style = "display:none" })%>
                                    <%: Html.CheckBox("TraCuocVC", LamSon.Commons.DataTypeProtect.ProtectBoolean(obj.TraCuocVC, false))%>
                                    <input type="submit" value="Lưu" class="button"/>
                                    <%       
                                   }
                                %></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.SanPham%> </a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaNhap.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaBaoBiBocVac.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney((Utilities.Protector.Double(obj.GiaNhap) + Utilities.Protector.Double(obj.CuocXeTangBo) + Utilities.Protector.Double(obj.GiaBaoBiBocVac)).ToString()) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(((Utilities.Protector.Double(obj.GiaNhap) + Utilities.Protector.Double(obj.CuocXeTangBo) + Utilities.Protector.Double(obj.GiaBaoBiBocVac)) * Utilities.Protector.Double(obj.SoLuong)).ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.NhapXuat%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.GiaXuat.ToString()) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0) * LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaXuat, 0))) + "-đ"%></a></td>
						        <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.BenTraVanChuyen%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(obj.NoThu) + "-đ"%></a></td>
						        <% if (obj.IdKhachHang >0)
                                   {
                                   %>
                                   <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title="<%= obj.KhachHang.MembershipName %>"><%= obj.KhachHang.MembershipName.ToString().Length > 20 ? obj.KhachHang.MembershipName.ToString().Substring(0, 20) : obj.KhachHang.MembershipName.ToString()%></a></td>
                                   <%
                                   }
                                   else
                                   { 
                                    %>
                                    <td></td>
                                   <%
                                   }
                                        %>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.ThanhToanTruoc, 0))) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.HinhThucTT  %></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString(LamSon.Commons.DataTypeProtect.ProtectDouble(obj.NoThu, 0) - LamSon.Commons.DataTypeProtect.ProtectDouble(obj.ThanhToanTruoc,0))) + "-đ"%></a></td>
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%: LamSon.Commons.Commons.FormatMoney(LamSon.Commons.DataTypeProtect.ProtectString((
                                                            (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaXuat, 0) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0)) -
                                                            (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.CuocXeTangBo, 0) +
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaNhap, 0) +
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.GiaBaoBiBocVac, 0)) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0)) -
                                                             (LamSon.Commons.DataTypeProtect.ProtectDouble(obj.SoLuong, 0) *
                                                             LamSon.Commons.DataTypeProtect.ProtectDouble(obj.CuocXeVanChuyen, 0)))) + "-đ"%></a></td>
						        
                                <td><a href="javascript:Edit(<%: idpage %>,'<%: obj.IdNKBH %>')" title=""><%= obj.GhiChu%></a></td>
                                
					        </tr>
                            <%
                                count++;
                        }                    
                    }
                   %>
                      </table>
			</div>
		</td> 
      <%
      }
      else
      { 
        %>
        <td valign="top">
			<div class="firstcol">           
                   <table class="LeftTable" cellspacing="0" cellpadding="0" >                   
                    <tr>
						<td class="tableFirstCol">
                        	
                        </td>
						<td></td>
					</tr>                    
                   </table>
			</div>
		</td>
		
		<td valign="top">
			<div class="table_div" onscroll="fnScroll()" >
				<table class="MainTable" cellspacing="0" cellpadding="0" >                  
                   <tr class='firstTr'>
						<td></td>
						<td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
						<td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
						<td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
						<td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
						<td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
					</tr>
                      </table>
			</div>
		</td>
        <%
      }
      %>